package ca.tatham.scheduler;

public class ResourceList extends PrioritizedQueue<Resource> {

	@Override
	protected int compare(Resource r1, Resource r2) {
		if (r1.getCeiling() > r2.getCeiling()) {
			return +1;
		}
		if (r1.getCeiling() < r2.getCeiling()) {
			return -1;
		}
		return 0;
	}

	Resource getResource(Object resource) {
		Node<Resource> n = getRoot();
		while (n.next != null) {
			if (n.next.element.getResource().equals(resource)) {
				return n.next.element;
			}
			n = n.next;
		}
		return null;
	}

}
